package cn.minimelon.solon.controller.warehouse;

import cn.minimelon.solon.domain.warehouse.CertCodeQueryVO;
import cn.minimelon.solon.service.warehouse.DeptBuyService;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.*;

@Slf4j
@Controller
@Mapping("/certCode")
public class CertCodeController {
    @Inject
    private DeptBuyService deptBuyService;

    @Post
    @Mapping("/find")
    public Integer selectErrorCertCode(CertCodeQueryVO query) {
        Thread thread = new Thread(() -> {
            try {
                deptBuyService.selectErrorCertCode(query);
            } catch (Exception e) {
                log.error("写入文件出错", e);
            }
        });
        thread.start();
        return 1;
    }

    @Post
    @Mapping("/selectErrorRegInfo")
    public Integer selectErrorRegInfo(CertCodeQueryVO query) {
        Thread thread = new Thread(() -> {
            try {
                deptBuyService.selectErrorRegInfo(query);
            } catch (Exception e) {
                log.error("写入文件出错", e);
            }
        });
        thread.start();
        return 1;
    }

    @Post
    @Mapping("/selectDistrInfo")
    public Integer selectDistrInfo(CertCodeQueryVO query) {
        Thread thread = new Thread(() -> {
            try {
                deptBuyService.selectDistrInfo(query);
            } catch (Exception e) {
                log.error("写入文件出错", e);
            }
        });
        thread.start();
        return 1;
    }

    @Post
    @Mapping("/readFile")
    public Integer readFile() {
        Thread thread = new Thread(() -> {
            try {
                String directoryPath = "D:/Z0Temp/20250612";
                deptBuyService.execReadFile(directoryPath);
            } catch (Exception e) {
                log.error("写入文件出错", e);
            }
        });
        thread.start();
        return 1;
    }
}
